//
//  Global.m
//  coocsless
//
//  Created by fabian on 07.03.11.
//  Copyright 2011 roboboogie.us. All rights reserved.
//

#import "Global.h"


@implementation Global
@synthesize language;
@synthesize _decades;
@synthesize _categories;
@synthesize mode;
@synthesize currentPage;

static Global *sharedGlobal = nil;

+ (Global*)sharedGlobal {
    if (sharedGlobal == nil) {
        sharedGlobal = [[super allocWithZone:NULL] init];
		
		// 0 ist detusch, 1 englisch, 2 niederländisch
		sharedGlobal.language = 0;
		sharedGlobal._decades = [[NSArray alloc] initWithObjects:@"JAHRZEHNTE",@"DECADES",nil]; 
		sharedGlobal._categories = [[NSArray alloc] initWithObjects:@"KATEGORIEN",@"CATEGORIES",nil]; 
		
		// homeView mit Jahrzehnten ist 0 // homeView mit Kategorien ist 1
		sharedGlobal.mode = 0;
		
		sharedGlobal.currentPage = arc4random() % 3;
	}
    return sharedGlobal;
}

+ (id)allocWithZone:(NSZone *)zone {
	@synchronized(self)
	{
		if (sharedGlobal == nil)
		{
			sharedGlobal = [super allocWithZone:zone];
			return sharedGlobal;
		}
	}
	return nil;
}

- (id)copyWithZone:(NSZone *)zone {
    return self;
}

- (id)retain {
    return self;
}

- (NSUInteger)retainCount {
    return NSUIntegerMax;  //denotes an object that cannot be released
}

- (void)release {
    //do nothing
}

- (id)autorelease {
    return self;
}

- (void)myGlobalFunction {
	self.language = 1;
}

- (NSArray *) getCategoriesTranslations {

	NSArray *translations =[NSArray alloc];
	
	switch (self.language) {
		case 0:
			translations = [NSArray arrayWithObjects:
							@"Architektur",
							@"Kunden",
							@"Marken",
							@"Mitarbeiter",
							@"Mode",
							@"Produktion",
							@"Sortiment",
							@"Warenwirtschaft",
							@"Werbung",
							@"Werbefilme" ,nil]; 
			break;
		case 1:
			translations = [NSArray arrayWithObjects:
							@"Architecture",
							@"Clients",
							@"Brands",
							@"Staff",
							@"Fashion",
							@"Production",
							@"Assortment",
							@"Logistics",
							@"Advertisment",
							@"Adversting Films" ,nil]; 
			break;
		case 2:
			
			break;
			
		default:
			break;
	}
	
	return translations;
}


- (NSArray *) getDecadeTranslations {
	
	NSArray *translations =[NSArray alloc];
	
	switch (self.language) {
		case 0 && 2:
			translations = [NSArray arrayWithObjects:
							@"1910er",
							@"1920er",
							@"1930er",
							@"1940er",
							@"1950er",
							@"1960er",
							@"1970er",
							@"1980er",
							@"1990er",
							@"2000er",
							@"2010er",nil]; 
			break;
		case 1:
			translations = [NSArray arrayWithObjects:
							@"1910s",
							@"1920s",
							@"1930s",
							@"1940s",
							@"1950s",
							@"1960s",
							@"1970s",
							@"1980s",
							@"1990s",
							@"2000s",
							@"2010s",nil]; 
			break;
			
		default:
			break;
	}
	
	return translations;
}

@end
